package com.bawei.a2010douyin.ui.xihuan;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bawei.a2010douyin.R;
import com.bawei.a2010douyin.base.mvp.BaseMvpFragment;
import com.bawei.a2010douyin.entity.VideoEntity;
import com.bawei.a2010douyin.widget.RecyclerViewItemDecoration;

import java.util.List;


public class XiHuanFragment extends BaseMvpFragment<XiHuanContract.IXiHuanView,XiHuanPresenter> implements XiHuanContract.IXiHuanView {
    private RecyclerView rv;
    private XiHuanAdapter mXiHuanAdapter;
    @Override
    public int bindLayout() {
        return R.layout.fragment_xi_huan;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        rv = (RecyclerView) findViewById(R.id.rv);
        mXiHuanAdapter = new XiHuanAdapter(R.layout.item_xihuan);
        rv.setAdapter(mXiHuanAdapter);
        rv.setLayoutManager(new StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.VERTICAL));
        //自定义分割线
        rv.addItemDecoration(new RecyclerViewItemDecoration(10,3));

    }

    @Override
    public XiHuanPresenter createPresenter() {
        return new XiHuanPresenter();
    }

    @Override
    public void initData() {
        mPresenter.getDianZanvideos();

    }

    @Override
    public void showDianzan(List<VideoEntity> data) {
        mXiHuanAdapter.getData().addAll(data);
        mXiHuanAdapter.notifyDataSetChanged();
    }
}